package com.zhdl.modules.prefiresys.web.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.project.common.service.impl.BaseServiceImpl;
import com.project.network.entity.PortComm;
import com.project.network.entity.PortSocket;
import com.project.network.repository.PortCommRepository;
import com.zhdl.modules.prefiresys.service.dto.BaseQueryCriteria;
import com.zhdl.modules.prefiresys.web.response.ComSerialResp;
import com.zhdl.modules.prefiresys.web.response.TcpSerialResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Slf4j
@Service
public class PorComServiceImpl  extends BaseServiceImpl<String, PortComm, PortCommRepository> {

    /**
     * 获取设备列表，带防区名称列表
     *
     * @return
     */
    public List<ComSerialResp> getAllComList() {

        BaseQueryCriteria bc = new BaseQueryCriteria();

        List<PortComm> list = findList(bc);

        List<ComSerialResp> outData = new ArrayList<>();

        for (PortComm item : list) {
            ComSerialResp detRes = new ComSerialResp();
            BeanUtil.copyProperties(item, detRes, CopyOptions.create().setIgnoreNullValue(true));
            detRes.setPosition("本机");
            detRes.setNamePort(detRes.getName() + detRes.getPort());
            outData.add(detRes);
        }

        return outData;
    }

}
